package com.meilian.product.controller;


import com.meilian.param.ProductCollectParam;
import com.meilian.product.service.ProductService;
import com.meilian.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 商品被收藏调用的Controller
 */
@RestController
@RequestMapping("product")
public class ProductCollectController {
    @Autowired
    private ProductService productService;


    @PostMapping("collect/list")
    public R productIds(@RequestBody @Validated ProductCollectParam productCollectParam, BindingResult result){
        if (result.hasErrors()) {
            return R.ok("没有收藏该数据!");
        }
        //根据已收藏的商品id查询相关信息
        return productService.ids(productCollectParam.getProductIds());
    }
}
